ASMOBJS=arch/i386/setjmp.S \
arch/i386/longjmp.S \
arch/i386/math/e_exp.S \
arch/i386/math/e_log.S \
arch/i386/math/s_sin.S \
arch/i386/math/s_cos.S \
arch/i386/math/s_floor.S \
arch/i386/math/s_ceil.S \
arch/i386/math/s_frexp.S \
arch/i386/math/s_fabs.S \
arch/i386/math/e_fmod.S \
arch/i386/math/e_atan2.S \
arch/i386/math/e_hypot.S \
arch/i386/math/e_pow.S \
arch/i386/math/s_finite.S \
arch/i386/math/s_scalbn.S \
arch/i386/math/e_log10.S 

OBJS= arch/i386/getpagesize.c \
src/os/syscall.c \
src/opendir.c \
src/readdir.c \
src/closedir.c \
src/rewinddir.c \
src/udivmoddi4.c \
src/sscanf.c \
src/stdlib/malloc.c \
src/stdlib/abort.c \
src/stdlib/getenv.c \
src/stdlib/strtol.c \
src/stdlib/strtoll.c \
src/stdlib/strtoul.c \
src/stdlib/strtoull.c \
src/stdlib/atoi.c \
src/stdlib/atol.c \
src/stdlib/atoll.c \
src/stdlib/atof.c \
src/stdlib/qsort.c \
src/stdlib/bsearch.c \
src/stdlib/abs.c \
src/stdlib/labs.c \
src/stdlib/llabs.c \
src/stdlib/strtod.c \
src/stdlib/mkstemp.c \
src/stdlib/random.c \
src/stdlib/srandom.c \
src/stdlib/rand.c \
src/stdlib/srand.c \
src/stdlib/mktemp.c \
src/string/memset.c \
src/string/memcpy.c \
src/string/memcmp.c \
src/string/memmove.c \
src/string/memchr.c \
src/string/strchr.c \
src/string/strrchr.c \
src/string/strlen.c \
src/string/strnlen.c \
src/string/strcmp.c \
src/string/strncmp.c \
src/string/strcasecmp.c \
src/string/strncasecmp.c \
src/string/strdup.c \
src/string/strndup.c \
src/string/strcpy.c \
src/string/strncpy.c \
src/string/strstr.c \
src/string/strerror.c \
src/string/strsignal.c \
src/string/strcat.c \
src/string/strncat.c \
src/string/strpbrk.c \
src/string/strspn.c \
src/string/strcspn.c \
src/string/strtok_r.c \
src/string/strtok.c \
src/unistd/sbrk.c \
src/unistd/fork.c \
src/unistd/execve.c \
src/unistd/execv.c \
src/unistd/execlp.c \
src/unistd/dup.c \
src/unistd/dup2.c \
src/unistd/write.c \
src/unistd/read.c \
src/unistd/pwrite.c \
src/unistd/pread.c \
src/unistd/exit.c \
src/unistd/getdents.c \
src/unistd/close.c \
src/unistd/execvp.c \
src/unistd/fchdir.c \
src/unistd/isatty.c \
src/unistd/lseek.c \
src/unistd/unlink.c \
src/unistd/readlink.c \
src/unistd/getcwd.c \
src/unistd/sleep.c \
src/unistd/access.c \
src/unistd/chdir.c \
src/unistd/ftruncate.c \
src/unistd/getpid.c \
src/unistd/getppid.c \
src/unistd/gettid.c \
src/unistd/link.c \
src/unistd/rmdir.c \
src/unistd/chown.c \
src/unistd/symlink.c \
src/unistd/ttyname.c \
src/unistd/pipe.c \
src/unistd/mmap.c \
src/unistd/alarm.c \
src/unistd/fpathconf.c \
src/unistd/getuid.c \
src/unistd/geteuid.c \
src/unistd/setuid.c \
src/unistd/setreuid.c \
src/unistd/getgid.c \
src/unistd/getegid.c \
src/unistd/setgid.c \
src/unistd/setregid.c \
src/unistd/gethostname.c \
src/unistd/getdtablesize.c \
src/unistd/getpgid.c \
src/unistd/setpgid.c \
src/unistd/getpgrp.c \
src/unistd/setpgrp.c \
src/fcntl/open.c \
src/fcntl/creat.c \
src/fcntl/fcntl.c \
src/stdio/support_bufio.c \
src/stdio/support_pf.c \
src/stdio/support_supcon.c \
src/stdio/stdio_internal.c \
src/stdio/streams.c \
src/stdio/ferror.c \
src/stdio/fgetc.c \
src/stdio/getc.c \
src/stdio/fgets.c \
src/stdio/fputc.c \
src/stdio/fputs.c \
src/stdio/fileno.c \
src/stdio/feof.c \
src/stdio/fflush.c \
src/stdio/ungetc.c \
src/stdio/clearerr.c \
src/stdio/fopen.c \
src/stdio/fdopen.c \
src/stdio/freopen.c \
src/stdio/fclose.c \
src/stdio/putc.c \
src/stdio/setvbuf.c \
src/stdio/fseek.c \
src/stdio/ftell.c \
src/stdio/fread.c \
src/stdio/fwrite.c \
src/stdio/rewind.c \
src/stdio/perror.c \
src/stdio/puts.c \
src/stdio/putchar.c \
src/stdio/rename.c \
src/stdio/remove.c \
src/stdio/fpurge.c \
src/time/tzset.c \
src/time/time_int.c \
src/time/strftime.c \
src/time/mktime.c \
src/time/ctime.c \
src/time/ctime_r.c \
src/time/localtime.c \
src/time/localtime_r.c \
src/time/asctime.c \
src/time/asctime_r.c \
src/time/gmtime.c \
src/time/gmtime_r.c \
src/time/gettimeofday.c \
src/time/ctime.c \
src/time/time.c \
src/time/nanosleep.c \
src/getopt/getopt.c \
src/getopt/getopt_long.c \
src/getopt/getopt_long_only.c \
src/sys/stat.c \
src/sys/fstat.c \
src/sys/stime.c \
src/sys/mkdir.c \
src/sys/ioctl.c \
src/sys/select.c \
src/sys/mount.c \
src/sys/umount.c \
src/sys/lstat.c \
src/sys/umask.c \
src/sys/chmod.c \
src/sys/utime.c \
src/sys/utimes.c \
src/sys/wait.c \
src/sys/wait3.c \
src/sys/wait4.c \
src/sys/waitpid.c \
src/sys/socket.c \
src/sys/connect.c \
src/ctype/isalpha.c \
src/ctype/isupper.c \
src/ctype/isblank.c \
src/ctype/islower.c \
src/ctype/isdigit.c \
src/ctype/isxdigit.c \
src/ctype/isalnum.c \
src/ctype/isspace.c \
src/ctype/isprint.c \
src/ctype/iscntrl.c \
src/ctype/tolower.c \
src/ctype/toupper.c \
src/ctype/toascii.c \
src/ctype/isgraph.c \
src/ctype/ispunct.c \
src/ctype/isascii.c \
src/signal/signal.c \
src/signal/sigaction.c \
src/signal/kill.c \
src/signal/killpg.c \
src/signal/raise.c \
src/signal/sigemptyset.c \
src/signal/sigfillset.c \
src/signal/sigaddset.c \
src/signal/sigdelset.c \
src/signal/sigismember.c \
src/signal/sigprocmask.c \
src/locale/localeconv.c \
src/locale/setlocale.c \
src/termios/tcflush.c \
src/termios/tcgetattr.c \
src/termios/tcsetattr.c \
src/termios/tcflow.c \
src/termios/tcgetpgrp.c \
src/termios/tcsetpgrp.c \
src/math/s_ldexp.c \
src/math/s_modf.c \
src/os/debug.c \
src/os/semaphore.c \
src/os/sysinfo.c \
src/os/region.c \
src/os/module.c \
src/os/os.c \
src/os/thread.c \
src/os/ipc.c \
src/pwd/getpwuid.c \
src/pwd/getpwent.c \
src/pwd/getpwnam.c \
src/pwd/endpwent.c \
src/pwd/setpwent.c \
src/network/inet_aton.c \
src/network/inet_ntoa.c 

# src/trio/trio.c \
# src/trio/trionan.c \
# src/trio/triostr.c \

START=src/start.c
STARTO= $(START:.c=.o) 
OBJO = $(OBJS:.c=.o) 
OBJSO= $(ASMOBJS:.S=.o)
OBJ=libc.a crt
CC=gcc -w -m32 -Wa,--32  -g -nostdlib -nostdinc -trigraphs  -I $(SDKDIR)/include -c
SDKDIR=../..

all: $(OBJ) 

libc.a: $(OBJO) $(OBJSO) 
	ar rcs $@ *.o
	cp libc.a $(SDKDIR)/lib/libc.a
	
crt: $(STARTO)
	cp start.o $(SDKDIR)/lib/crt_c.o
	rm *.o
	
%.o: %.c
	$(CC) $<
	
%.o: %.S
	$(CC) $<

clean:
	rm -f $(OBJ) *.o *.a
